package main

import (
	"awesomeProject2/grpc_client/service"
	"context"
	"google.golang.org/grpc"
	"log"
	"os"
)

func main() {
	conn, err := grpc.Dial(":8788", grpc.WithInsecure())
	if err != nil {
		log.Fatal(err)
	}
	// 退出时关闭链接
	defer conn.Close()
	// 2. 调用Product.pb.go中的NewProdServiceClient方法
	productServiceClient := service.NewWaiterClient(conn)
	res := "test123"
	// os.Args[1] 为用户执行输入的参数 如：go run ***.go 123
	if len(os.Args) > 1 {
		res = os.Args[1]
	}
	resp, err := productServiceClient.DoMD5(context.Background(), &service.Req{JsonStr: res})
	if err != nil {
		log.Fatalf("could not greet: %v", err)
	}
	log.Printf("服务端响应: %s", resp.BackJson)

}
